package org.example.common.core.model;

import lombok.Data;
import lombok.Getter;
import org.example.common.core.enums.ResultCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : [Pashm]
 * @version : [v1.0]
 */
@Data
public class TableDataInfo {
    //总记录数
    private long total;

    //列表数据
    private List<?> rows;

    //消息状态码；
    private int code;

    //消息内容
    private String msg;

    //表格数据对象
    public TableDataInfo(){

    }

    public static TableDataInfo empty(){
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(ResultCode.SUCCESS.getCode());
        rspData.setRows(new ArrayList<>());
        rspData.setMsg(ResultCode.SUCCESS.getMsg());
        rspData.setTotal(0);
        return rspData;
    }

    public static TableDataInfo success(List<?> list, long total){
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(ResultCode.SUCCESS.getCode());
        rspData.setRows(list);
        rspData.setMsg(ResultCode.SUCCESS.getMsg());
        rspData.setTotal(total);
        return rspData;
    }

}
